<?php

namespace App\Utils\Sms;

## 第三方未知短信
use function Symfony\Component\Translation\t;

class UnKnownSms implements SmsInterface
{
    public string $signName = '';

    /**
     * 构造函数
     * @param string $signName
     */
    public function __construct(string $signName)
    {
        $this->signName = $signName;
    }

    /**
     * 设置短信签名
     * @param bool $includeBracket
     * @return string
     */
    public function setSignName(bool $includeBracket): string
    {
        return $includeBracket ? '【'. $this->signName . '】' : $this->signName;
    }

    /**
     * 发送验证码
     * @param string $mobile
     * @param int $verifyCode
     * @return bool
     */
    public function send(string $mobile, int $verifyCode): bool
    {
        $url = 'http://139.224.195.110:8513/sms/Api/Send.do';
        $data = [
            'SpCode' => '100045',
            'LoginName' => '博来软件',
            'Password' => '!Z85BLra@',
            'UserNumber' => $mobile,
            'MessageContent' => $this->setSignName(true) . '验证码为：'. $verifyCode .'，您正在注册成为绒博汇用户，感谢您的支持！'
        ];
        $url = $url . '?' . http_build_query($data);
        $response = curlGet($url);
        return !(!str_contains($response, 'result=0'));
    }
}
